package com.yanqu.road.server.cmd.activity.shuihuyezicard;

import com.yanqu.road.pb.activity.ShuiHuYeZiCardProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.shuihuyezicard.ShuiHuYeZiCardMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;


/**
 * @Description
 * @Author cwq
 * @Data 2021/12/9 11:33
 */
@Cmd(code = GameProtocol.S_SHUIHUYEZICARD_CANCEL_MATCH_FROM_CROSS, desc = "水浒叶子牌 取消匹配 跨服返回区服 协议")
public class ShuiHuYeZiCardCancelMatchFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ShuiHuYeZiCardProto.ShuiHuYeZiCardCancelMatchGameToServerMsg crossMsg = ShuiHuYeZiCardProto.ShuiHuYeZiCardCancelMatchGameToServerMsg.parseFrom(packet.getBytes());
        if(crossMsg.getStcMsg().getRet() == 0){
            // 成功取消匹配
            ShuiHuYeZiCardMgr.cancelMatch(player, crossMsg.getRoomType());
        }
        player.sendPacket(ClientProtocol.U_SHUIHUYEZICARD_CANCEL_WAITING,crossMsg.getStcMsg().toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
